<template>
  <div class="domain-userhome" v-touch:right="onSwipeRight" v-touch:left="onSwipeLeft">
    <index_top></index_top>
    <div class="container">
      <!-- el容器 -->
      <div class="el-container">
        <!--左边导航 -->
        <el-aside v-bind:class="isHide>1?'navShow':'navHide'" height="100%" style="width: 20%;" ref="nav">
          <!-- 左边用户信息 -->
          <div class="user-info">
            <!-- 头像 -->
            <div class="user-avatar">
                <a href="javascript:void(0)"><img :src="this.$store.getters.loginData.avatar" /></a>
                <i class="user-ident" :style="this.$store.getters.loginData.bigV>0?islargV:''"></i>
            </div>
            <!-- 经验条-->
            <div class="user-exp">
              <span>LV：10</span>
              <el-progress :text-inside="true" :stroke-width="12" :percentage="70"></el-progress>
              <span>LV：11</span>
            </div>
          </div>
          <!-- 左边菜单-->
          <div clsas="user-menu">
            <el-menu :unique-opened="true"
              router
              class="el-menu-vertical-demo"
              :collapse="isCollapse"
              :default-active="default_active"
              @select="changeMenu"
              active-text-color="red">

              <el-menu-item index="usercenter">
                <i class="el-icon-monitor"></i>
                <span slot="title">首页</span>
              </el-menu-item>

              <el-menu-item index="publish_aritcle" v-if="$store.getters.loginData.canPublish>0">
                <i class="el-icon-edit-outline"></i>
                <span slot="title">发布文章</span>
              </el-menu-item>

              <el-menu-item index="userinfo">
                <i class="el-icon-s-custom"></i>
                <span slot="title">个人信息</span>
              </el-menu-item>

              <el-menu-item index="articleManager">
                <i class="el-icon-document"></i>
                <span slot="title">文章管理</span>
              </el-menu-item>

              <el-menu-item index="commentManager">
                <i class="el-icon-s-comment"></i>
                <span slot="title">评论管理</span>
              </el-menu-item>

              <el-menu-item index="5">
                <i class="el-icon-setting"></i>
                <span slot="title">个性设置</span>
              </el-menu-item>

              <el-menu-item index="7">
                <i class="el-icon-folder-opened"></i>
                <span slot="title">我的收藏</span>
              </el-menu-item>

            </el-menu>
          </div>
        </el-aside>
        <!--右边页面 -->
        <el-container class="page-box">
            <router-view/>
        </el-container> 
      </div>
    </div>
  </div>
</template>
<script>
import index_top from "../index/index_top";
import publish_aritcle from "./children/publish_aritcle";
export default {
  components: {
    index_top,
    publish_aritcle
  },
  data() {
    return {
      islargV:{
        'background-position': '-50px -25px'
      },
      isCollapse: false,
      default_active:'',
      isHide:1
    };
  },
  created: function() {
    //判断是否登录
    this.default_active=this.$route.name
    if(!this.$store.getters.loginData.islogin){
      this.$router.push({path:'/'})
    }
    //判断屏幕宽度
    var screenWidth=document.body.clientWidth;
    if(screenWidth<500){
      this.$notify.success({
            title: '通知',
            message: '欢迎访问本站,您可以左右滑动显示或隐藏菜单了哦!'
      });
    }
  },
  methods:{
    onSwipeRight(){
      this.isHide=2;
    },
    onSwipeLeft(){
      this.isHide=1;
    },
    changeMenu(){
      this.isHide=1;
    }
  }
};
</script>
<style scoped>
@media screen and (max-width: 500px){
    .page-box{
      width: 500px;
      overflow: hidden;
    }
    @keyframes navShow
    {
      from {width:0px;}
      to {width:200px;}
    }
    @-webkit-keyframes navShow /*Safari and Chrome*/
    {
      from {width:0px;}
      to {width:200px;}
    }
    @keyframes navHide
    {
      from {width:200px;}
      to {width:0px;}
    }
    @-webkit-keyframes navHide /*Safari and Chrome*/
    {
      from {width:200px;}
      to {width:0px;}
    }
    .navHide{
      width:200px !important;
      overflow: hidden;
      animation:navHide 0.5s ease-in-out 0s 1 forwards;
      -webkit-animation:navHide 0.5s ease-in-out 0s 1 forwards;
    }
    .navShow{
      width:200px !important;
      overflow: hidden;
      animation:navShow 0.5s ease-in-out 0s 1 forwards;
      -webkit-animation:navShow 0.5s ease-in-out 0s 1 forwards;
    }
    .el-progress{
      width: 80px !important;
    }
    .user-exp span,.el-progress >>> .el-progress-bar__innerText{
      margin-top: -3px;
    }
    .el-container:first-child {
      border: none !important;
      border-radius: 0px !important;
      margin-top: 0 !important;
    }
    .el-menu{
      width: 200px;
    }
    .user-info {
      width: 200px;
    }
}
.el-menu{
  background-color:transparent;
}
.el-menu >>> .el-menu-item{
  height: 40px;
  line-height: 40px;
  text-align: center;
}
.user-ident {
  display: inline-block;
  background-image: url(../../../static/images/icon.png);
  background-repeat: no-repeat;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
  vertical-align: -2px;
  background-position: -50px -75px;
  position: relative;
  top: -30px;
  left: 45px;
}
.user-exp span,.el-progress >>> .el-progress-bar__innerText{
  font-size: 10px;
  margin-top: -3px;
}
.el-progress{
    display: inline-block;
    width: 120px;
}
.el-aside {
  border-right: 1px solid #ccc;
}
.el-container:first-child {
  border: 1px solid #ccc;
  margin-top: 5px;
  border-radius: 10px;
  background: rgba(0,0,0,0.1);
}
.user-exp{
  padding: 0px 0px 15px 0px;
}
.user-info {
  text-align: center;
  border-bottom: 1px solid #ccc;
}
.user-avatar{
  width: 90px;
  height: 90px;
  margin: 0px auto;
  padding: 15px 0px;
}
.user-avatar img{
  width: 100%;
  height: 100%;
  border-radius: 100%;
  border: 6px solid #ccc;
}
.user-avatar img:hover {
  box-shadow: 0 0 10px #5db8f8;
}
</style>
<style >
* {
  margin: 0;
  padding: 0;
}
.page-title {
  border-bottom: 1px solid #ccc;
  color: #333;
  font-size: 16px;
  padding: 5px;
  border-top-left-radius: 3px;
  border-top-right-radius: 3px;
}
@media screen and (min-width: 1200px) {
  .container {
    max-width: 1200px;
    margin: 0px auto;
  }
}
@media screen and (max-width: 500px){
    .delete-tip{
        width: 350px;
        margin-top: -50px;
    }
}
</style>